package com.han.verifycode.data;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Position implements Comparable<Position> {
    private Integer x;
    private Integer y;

    @Override
    public int compareTo(Position p) {
        boolean xBigger = x - p.getX() > 0;
        boolean yBigger = x == p.getX() && y - p.getY() > 0;
        if (xBigger || yBigger) {
            return 1;
        }
        if (x == p.getX() && y == p.getY()) {
            return 0;
        }
        return -1;
    }
}
